﻿using System;
using System.Diagnostics;

namespace MesopotamiaDCProxy
{
    public static class WebLogger
    {
        /// <summary>
        /// Log informational message        
        /// </summary>
        /// <param name="logMessage">string message to be logged</param>
        [Conditional("DEBUG")]
        public static void LogDebug(string logMessage)
        {
            LogMessage(logMessage);
        }

        private static void LogMessage(string logMessage)
        {
            // write the log message
            Trace.WriteLine(string.Format("{0}:{1}:{2} ", DateTime.Now.TimeOfDay, System.Threading.Thread.CurrentThread.ManagedThreadId, logMessage));
        }

        /// <summary>
        /// Log a warning message
        /// </summary>
        /// <param name="logMessage">string message to be logged</param>
        public static void LogWarn(string logMessage)
        {
            // write the log message
            LogMessage("Warning : " + logMessage);
        }

        /// <summary>
        /// Log an Exception and message
        /// </summary>
        /// <param name="logMessage">String message or area of exception</param>
        /// <param name="exception">Exception thrown</param>
        public static void LogException(string logMessage, Exception exception)
        {
            // log the message
            LogMessage("Exception : " + exception.Message + "\r\n" + exception.StackTrace + "\r\n" + logMessage);
        }
    }
}